package month_04.day03;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Demo2 {
    private static int num=0;
    private static synchronized  void add(){
        num++;
    }
    public static class T extends Thread{
        @Override
        public void run() {
            for(int i=0;i<100;i++){
                Demo2.add();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        T t1=new T();
        T t2=new T();
        T t3=new T();
        t1.start();
        t2.start();
        t3.start();
        t1.join();
        t2.join();
        t3.join();
        int j=1;
        for(int i=0;i<100;i++){
            j=++j;
        }
        System.out.println(j);
        System.out.println(Demo2.num);
    }
}
